/*  p2_6.c: Toggling all bits of Port A at 16 Hz (25 ms on, 25 ms off) */


#include "TM4C123GH6PM.h"

void delayMs(int n);

int main(void)
{
    /* enable clock to GPIOA at clock gating control register */
    SYSCTL->RCGCGPIO |= 1;
    /* enable the GPIOA pins as output */
    GPIOA->DIR = 0xFF;
    /* enable the GPIOA pins for digital function */
    GPIOA->DEN = 0xFF;
    
    while(1)
    {
        GPIOA->DATA = 0xFF; /* turn on all the pins of Port A */
        delayMs(25);
        
        GPIOA->DATA = 0;    /* turn off all the pins of Port A */
        delayMs(25); 
    }
}

/* delay n milliseconds (16 MHz CPU clock) */
void delayMs(int n)
{
    int i, j;
    for(i = 0 ; i < n; i++)
        for(j = 0; j < 3180; j++)
            {}  /* do nothing for 1 ms */
}

/* This function is called by the startup assembly code to perform system specific initialization tasks. */

void SystemInit(void)
{
    /* Grant coprocessor access */
    /* This is required since TM4C123G has a floating point coprocessor */
    SCB->CPACR |= 0x00f00000;